using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;
using SailHero.Soft.FrameWork.Models;

namespace SailHero.Soft.FrameWork.Mapping.HJT212DB
{
    public class BaseHistoryDataMap : EntityTypeConfiguration<BaseHistoryData>
    {
        public BaseHistoryDataMap()
        {
            // Primary Key
            this.HasKey(t => new { t.P_ID, t.ParamID, t.CollectionDateTime });

            // Properties
            this.Property(t => t.P_ID)
                .IsRequired()
                .HasMaxLength(36);

            this.Property(t => t.ParamID)
                .IsRequired()
                .HasMaxLength(10);

            this.Property(t => t.DataState)
                .IsFixedLength()
                .HasMaxLength(1);

            // Table & Column Mappings
            this.ToTable("BaseHistoryData");
            this.Property(t => t.P_ID).HasColumnName("P_ID");
            this.Property(t => t.ParamID).HasColumnName("ParamID");
            this.Property(t => t.CollectionDateTime).HasColumnName("CollectionDateTime");
            this.Property(t => t.ParamValue).HasColumnName("ParamValue");
            this.Property(t => t.IsEdited).HasColumnName("IsEdited");
            this.Property(t => t.SaveTime).HasColumnName("SaveTime");
            this.Property(t => t.DataState).HasColumnName("DataState");
        }
    }
}
